package mt.omid.jscap.operaion;

/****
 * Create by Omid Mehdizadeh
 * Copyright 2010, Omid Mehdizadeh
 * Based on JDiameter Open Source Project
 */

import java.util.Date;

import mt.omid.jscap.Tools;

import org.jdiameter.api.ApplicationId;
import org.jdiameter.api.AvpSet;
import org.jdiameter.api.InternalException;
import org.jdiameter.api.RawSession;
import org.jdiameter.api.Request;
import org.jdiameter.api.Session;
import org.jdiameter.api.SessionFactory;
import org.jdiameter.api.app.AppSession;
import org.jdiameter.client.api.IContainer;
import org.jdiameter.client.impl.SessionFactoryImpl;
import org.jdiameter.common.api.app.IAppSessionFactory;

import com.sun.tools.example.debug.bdi.SessionListener;

import static mt.omid.jscap.SCAPCode.*;
import static org.jdiameter.api.Avp.ACCT_APPLICATION_ID;
import static org.jdiameter.api.Avp.ACC_RECORD_NUMBER;
import static org.jdiameter.api.Avp.ACC_RECORD_TYPE;
import static org.jdiameter.api.Avp.ORIGIN_HOST;
import static org.jdiameter.api.Avp.ORIGIN_REALM;
import static org.jdiameter.api.Avp.VENDOR_ID;
import static org.jdiameter.api.Avp.VENDOR_SPECIFIC_APPLICATION_ID;
import static org.jdiameter.api.Message.ACCOUNTING_REQUEST;


//public class SCAPSessionFactory implements IAppSessionFactory
public class SCAPSessionFactory extends SessionFactoryImpl
{

    IContainer     stack;
    SessionFactory fact;


    public SCAPSessionFactory( IContainer stack, SessionFactory sf )
    {
	super( stack );
	this.stack = stack;
	this.fact = sf;
    }

    public SCAPSession getSCAPSession( String sid, SessionListener sl ) throws InternalException
    {
	return new SCAPSession( this.stack, sid, this.fact, sl );
    }

    public AppSession getNewSession( String arg0, Class<? extends AppSession> arg1,
				     ApplicationId arg2, Object [] arg3 )
    {
	try
	{
	    return this.getSCAPSession( null, null );
	}
	catch( InternalException e )
	{
	    e.printStackTrace();
	    return null;
	}
    }

}
